package com.banzhi.shop.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.banzhi.shop.R;

import com.banzhi.shop.data.GoodsBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2018/6/6.
 */

public class HomeAdapter extends BaseQuickAdapter<GoodsBean,BaseViewHolder> {

    public HomeAdapter(int layoutResId, @Nullable List<GoodsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsBean item) {
        helper.setText(R.id.tv_home_content,item.getTitle())
              .setText(R.id.tv_price,item.getMarketprice())
              .setText(R.id.tv_liyun,item.getProfit())
              .setText(R.id.tv_kucun,item.getTotal())
              .setText(R.id.tv_Peoplenum,item.getSharebtn())
                .addOnClickListener(R.id.iv_add_dianpu)
                .addOnClickListener(R.id.iv_add_image)
                .addOnClickListener(R.id.iv_fenxiang);
      /*  if ("0".equals(item.getIcon())) {
            helper.setImageResource(R.id.iv_add_dianpu, R.mipmap.jian1);
            helper.addOnClickListener(R.id.iv_add_dianpu);
        } else if ("1".equals(item.getIcon())) {
            helper.setImageResource(R.id.iv_add_dianpu, R.mipmap.jia1);
            helper.addOnClickListener(R.id.iv_add_dianpu);
        }*/
        Glide.with(mContext).load(item.getThumb()).placeholder( R.mipmap.recyclerview_item).into((ImageView) helper.getView(R.id.img_home));

    }
}
